using System;
using System.Collections.Generic;
using System.Text;

namespace MspEmulator
{
    class enableHighVoltage: ISend, IUpdateDevice
    {
        private bool HVenable;

        public enableHighVoltage(byte enable) 
        {
            HVenable = enable == 1? true: false;
        }
        
        #region IUpdateDevice Members

        public void updateDevice()
        {
            Device.highVoltageOn = HVenable;
            if (HVenable)
            {
                Device.sysState = (byte)Utility.systemStates.Ready;
                Serial.Send(Utility.buildPack(Utility.collectData((byte)Utility.replyesAsync.HighVoltageOn)));
            }
            else
            {
                Device.sysState = (byte)Utility.systemStates.WaitHighVoltage;
                Serial.Send(Utility.buildPack(Utility.collectData((byte)Utility.replyesAsync.HighVoltageOff)));
            }
        }

        #endregion

        #region ISend Members

        public void Send()
        {
            Serial.Send(Utility.buildPack(Utility.collectData((byte)Utility.functCode.EnableHighVoltage)));
        }

        #endregion
    }
}
